package main

import "fmt"

//
//定义 -
//创建、访问
//结构体方法

type student struct {
	name  string
	age   int
	email string
}

func (s student) getName() string {
	return s.name
}

func (s student) getAge() int {
	return s.age
}

func mainStruct() {

	//创建
	xiaoMing := student{
		name: "xiaoMing",
		age:  22,
		//email: "xiaoming@163.com",
	}

	xiaoMing.email = "xiaoming@163.com"
	fmt.Printf("%+v\n", xiaoMing)
	fmt.Println("调用结构体方法：name", xiaoMing.getName())
	fmt.Println("调用结构体方法:age", xiaoMing.getAge())
	fmt.Println("直接访问:name", xiaoMing.name)
	fmt.Println("直接访问:email", xiaoMing.email)
}
